﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link type="text/css" rel="stylesheet" media="all" href="../styles/global.css"/>
    <link type="text/css" rel="stylesheet" media="all" href="../styles/global_color.css"/>
    <script src="../js/jquery-3.2.1.js"></script>
    <script language="javascript" type="text/javascript">
        $.ajax({
            url: "/selectAllModules",
            type: "post",
            success: function (result) {
                console.log(result)

                if (result.indexOf("角色管理") == -1) {
                    document.getElementById("lia1").style.display = "none"
                }
                if (result.indexOf("管理员管理") == -1) {
                    document.getElementById("lia2").style.display = "none"
                }
                if (result.indexOf("资费管理") == -1) {
                    document.getElementById("lia3").style.display = "none"
                }
                if (result.indexOf("账务账号管理") == -1) {
                    document.getElementById("lia4").style.display = "none"
                }
                if (result.indexOf("业务账号管理") ==-1) {
                    document.getElementById("lia5").style.display = "none"
                }
                if (result.indexOf("账单管理") ==-1) {
                    document.getElementById("lia6").style.display = "none"
                }
                if (result.indexOf("报表管理") == -1) {
                    document.getElementById("lia7").style.display = "none"
                }
            }
        });


        var adminId = 0;
        $.ajax({
            url: "selectuser",
            type: "post",
            success: function (result) {
                console.log(result)
                var admin = result.data;
                var roleList = admin.roleList;
                var content = "";
                for (var i in roleList) {
                    var role = roleList[i];
                    var rolename = role.name + ",";
                    content += rolename;
                }
                adminId = admin.adminId;
                $("#admincode").val(admin.adminCode);
                $("#role").val(content);
                $("#name").val(admin.name);
                $("#tel").val(admin.telephone);
                $("#email").val(admin.email);
                $("#createtime").val(admin.enrolldate);
            }
        })

        //保存成功的提示信息
        function showResult() {
            $.ajax({
                url: "updateuser",
                type: "post",
                data: {
                    adminId: adminId,
                    name: $("#name").val(),
                    tel: $("#tel").val(),
                    email: $("#email").val(),
                },
                success: function (result) {
                    if (result.message!="修改成功"){
                        alert(result.message);
                    }else {
                        alert(result.message);
                        window.location.href = 'index'
                    }
                }
            })

        }
        function showResultDiv(flag) {
            var divResult = document.getElementById("save_result_info");
            if (flag)
                divResult.style.display = "block";
            else
                divResult.style.display = "none";
        }
    </script>
</head>
<body>
<!--Logo区域开始-->
<div id="header">
    <img src="../images/logo.png" alt="logo" class="left"/>
    <a href="/logout">[退出]</a>
</div>
<!--Logo区域结束-->
<!--导航区域开始-->
<div id="navi">
    <ul id="menu">
        <li><a href="../index.html" class="index_off"></a></li>
        <li id="lia1"><a href="rolelist" class="role_off"></a></li>
        <li id="lia2"><a href="adminlist" class="admin_off"></a></li>
        <li id="lia3"><a href="fee" class="fee_off"></a></li>
        <li id="lia4"><a href="accountlist" class="account_off"></a></li>
        <li id="lia5"><a href="servicelist" class="service_off"></a></li>
        <li id="lia6"><a href="bill" class="bill_off"></a></li>
        <li id="lia7"><a href="report" class="report_off"></a></li>
        <li><a href="userinfo" class="information_on"></a></li>
        <li><a href="changepsw" class="password_off"></a></li>
    </ul>
</div>
<!--导航区域结束-->
<!--主要区域开始-->
<div id="main">
    <!--保存操作后的提示信息：成功或者失败-->
    <div id="save_result_info" class="save_success">保存成功！</div><!--保存失败，数据并发错误！-->
    <form action="" method="" class="main_form">
        <div class="text_info clearfix"><span>管理员账号：</span></div>
        <div class="input_info"><input type="text" readonly="readonly" class="readonly" value="" id="admincode"/></div>
        <div class="text_info clearfix"><span>角色：</span></div>
        <div class="input_info">
            <input type="text" readonly="readonly" class="readonly width400" value="" id="role"/>
        </div>
        <div class="text_info clearfix"><span>姓名：</span></div>
        <div class="input_info">
            <input type="text" value="" id="name"/>
            <span class="required">*</span>
            <div class="validate_msg_long error_msg">20长度以内的汉字、字母的组合</div>
        </div>
        <div class="text_info clearfix"><span>电话：</span></div>
        <div class="input_info">
            <input type="text" class="width200" value="" id="tel"/>
            <div class="validate_msg_medium">电话号码格式：手机或固话</div>
        </div>
        <div class="text_info clearfix"><span>Email：</span></div>
        <div class="input_info">
            <input type="text" class="width200" value="" id="email"/>
            <div class="validate_msg_medium">50长度以内，符合 email 格式</div>
        </div>
        <div class="text_info clearfix"><span>创建时间：</span></div>
        <div class="input_info"><input type="text" readonly="readonly" class="readonly" value="" id="createtime"/></div>
        <div class="button_info clearfix">
            <input type="button" value="保存" class="btn_save" onclick="showResult();"/>
            <input type="button" value="取消" class="btn_save" onclick="location.href='index'"/>
        </div>
    </form>
</div>
<!--主要区域结束-->
<div id="footer">
    <p>[源自北美的技术，最优秀的师资，最真实的企业环境，最适用的实战项目]</p>
    <p>版权所有(C)云科技有限公司 </p>
</div>
</body>
</html>
